﻿Public Class FTestSearch

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetId.Click
        With OpenMediaInfo.IMDB.Search.GetImdbIdByTitle(cboTitle.Text)
            If .Id Is Nothing Then
                txtIdResult.Text = "Inconclusive"
            Else
                txtIdResult.Text = .Id
            End If
            Dim strTmpFile As String = IO.Path.GetTempFileName
            Dim strHtmlFile As String = strTmpFile & ".html"
            IO.File.WriteAllText(strHtmlFile, .Html)
            IO.File.Delete(strTmpFile)
            txtHtml.Text = .Html
            TabControl1.SelectedTab = TabPage1
        End With
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim aTitles As Generic.List(Of OpenMediaInfo.IMDB.Search.FoundTitle)
        aTitles = OpenMediaInfo.IMDB.Search.GetAllTitlesFromSearchResult(txtHtml.Text)
        ListView1.BeginUpdate()
        ListView1.Items.Clear()
        For Each clsTitle As OpenMediaInfo.IMDB.Search.FoundTitle In aTitles
            With ListView1.Items.Add(clsTitle.Id)
                .SubItems.Add(clsTitle.Type.ToString)
                .SubItems.Add(clsTitle.Name)
                .SubItems.Add(clsTitle.Year)
            End With
        Next
        ListView1.EndUpdate()
        TabControl1.SelectedTab = TabPage2
    End Sub
End Class

